package com.wutao.panzh.admin.service.Impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.panzh.entity.index.UserInfo;
import com.panzh.util.StringUtil;
import com.wutao.panzh.admin.mapper.UserInfoMapper;
import com.wutao.panzh.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    private UserInfoMapper userInfoMapper;


    @Override
    public PageInfo<UserInfo> getUserInfoPageInfo(Integer pageNo, Integer pageSize, String keyword) {
        PageHelper.startPage(pageNo,pageSize);
        List<UserInfo> userInfos = userInfoMapper.selectUserInfoForSeach(keyword);
        PageInfo<UserInfo> info = new PageInfo<>(userInfos);
        return info;
    }

    @Override
    public void resetPassWordUserInfo(String userlId) {
        String newPasswoed = StringUtil.md5("12345");
        userInfoMapper.resetPassWordUserInfo(userlId,newPasswoed);
    }

    @Override
    public void deleteUserInfo(String userlId) {
        userInfoMapper.deleteUserInfo(userlId);
    }

    @Override
    public void savaUserInfo(String nickName, String password, String tel, String sex) {
        password = StringUtil.md5(password);
        userInfoMapper.insertUerInfoSimple(nickName,password,tel,sex);
    }

    @Override
    public List<UserInfo> selectAllByTel(String tel) {
        List<UserInfo> list = userInfoMapper.selectAllByTel(tel);
        return list;
    }
}
